import 'dart:convert';

Group groupFromJson(String str) => Group.fromJson(json.decode(str));

String groupToJson(Group data) => json.encode(data.toJson());

class GroupModel {
  int status = 0;
  String message;
  List<Group> data;

  GroupModel({this.status, this.message, this.data = const []});

  GroupModel.fromJson(Map<String, dynamic> json) {
    status = json['status'];
    message = json['message'];
    if (json['data'] != null) {
      data = new List<Group>();
      json['data'].forEach((v) {
        data.add(new Group.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['status'] = this.status;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Group {
  Group(
      {this.id,
      this.logo,
      this.webLink,
      this.createrId,
      this.userId,
      this.groupId,
      this.summary,
      this.name,
      this.role,
      this.note,
      this.checked,
      this.owner,
      this.applierId});

  String id;
  String logo;
  String webLink;
  String createrId;
  String groupId;
  String userId;
  String applierId;
  String summary;
  String name;
  String note;
  num role;
  bool checked;
  bool owner;
  // int v;

  factory Group.fromJson(Map<String, dynamic> json) => Group(
      id: json["_id"],
      logo: json["logo"],
      webLink: json["web_link"],
      createrId: json["creater_id"],
      summary: json["summary"],
      name: json["name"],
      note: json["note"],
      checked: json['checked'],
      groupId: json['group_id'],
      userId: json['user_id'],
      applierId: json['applier_id'],
      owner: json['owner'],
      role: json['role']
      // v: json["__v"],
      );

  Map<String, dynamic> toJson() => {
        "_id": id,
        "logo": logo,
        "web_link": webLink,
        "creater_id": createrId,
        "summary": summary,
        "name": name,
        "note": note,
        "checked": checked,
        "group_id": groupId,
        "user_id": userId,
        "applier_id": applierId,
        "owner": owner,
        "role": role,
        // "__v": v,
      };
}
